package org.jeecg.modules.qyxx.service.impl;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.qyxx.entity.BgFpHzNdFxyj;
import org.jeecg.modules.qyxx.entity.BgFpHzNdQtzyzc;
import org.jeecg.modules.qyxx.enumdemo.RedisKeyConstant;
import org.jeecg.modules.qyxx.mapper.BgFpHzNdFxyjMapper;
import org.jeecg.modules.qyxx.service.IBgFpHzNdFxyjService;
import org.jeecg.modules.qyxx.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 发票风险预警汇总数据
 * @Author: ZJJ
 * @Date: 2021-06-10
 * @Version: V1.0
 */
@Service
// @DS("multi-datasource1")申报
public class BgFpHzNdFxyjServiceImpl extends MppServiceImpl<BgFpHzNdFxyjMapper, BgFpHzNdFxyj> implements IBgFpHzNdFxyjService {
    @Autowired
    private BgFpHzNdFxyjMapper bgFpHzNdFxyjMapper;

    @Override
    public Object fpHzNdFxyj(String djxh,List<String> tjnds) {
        LambdaQueryWrapper<BgFpHzNdFxyj> wrapper = Wrappers.lambdaQuery(BgFpHzNdFxyj.class);
        // List<Object> tjnds =  bgFpHzNdFxyjMapper.selectObjs(wrapper);
        //String tjnd = tjnds.get(tjnds.size() - 1);
        // TODO 这里的2019需要改成tjnd
        List<Object> list = new ArrayList<>();
        // int i = 0;
        for (String tjnd : tjnds) {
            wrapper.clear();
            wrapper.eq(BgFpHzNdFxyj::getDjxh, djxh).eq(BgFpHzNdFxyj::getTjnd, tjnd);
            BgFpHzNdFxyj bgFpHzNdFxyj = bgFpHzNdFxyjMapper.selectOne(wrapper);
            // List<Map<String, Object>> maps = bgFpHzNdFxyjMapper.selectMaps(wrapper);
            if (bgFpHzNdFxyj == null) {
                continue;
            }
            // i++;
            Map<String, Object> map1 = new HashMap<>();
            map1.put("hcje", bgFpHzNdFxyj.getHcje());
            map1.put("hcsl", bgFpHzNdFxyj.getHcsl());
            map1.put("tjnd", bgFpHzNdFxyj.getTjnd());

            Map<String, Object> map2 = new HashMap<>();
            map2.put("skje", bgFpHzNdFxyj.getSkje());
            map2.put("sksl", bgFpHzNdFxyj.getSksl());
            map2.put("tjnd", bgFpHzNdFxyj.getTjnd());

            Map<String, Object> map3 = new HashMap<>();
            map3.put("zfje", bgFpHzNdFxyj.getZfje());
            map3.put("zfsl", bgFpHzNdFxyj.getZfsl());
            map3.put("tjnd", bgFpHzNdFxyj.getTjnd());
            list.add(map1);
            list.add(map2);
            list.add(map3);
            /*if (i >= 3) {
                break;
            }*/
            //wrapper.eq(BgFpHzNdFxyj::getDjxh,djxh).eq(BgFpHzNdFxyj::getTjnd,tjnd);
            // List<Map<String, Object>> maps = bgFpHzNdFxyjMapper.selectMaps(wrapper);
            //map.put(tjnd,maps);
        }
        return list;
    }
}
